package com.hxzy.es.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * ES实体集
 */
@Document(indexName = "hxzy_mall",createIndex = false)
@Getter
@Setter
public class EsGoodsInfo implements Serializable {

    @Id
    @Field(name = "id",type = FieldType.Long)
    private Long id;

    @Field(name = "goods_name",type = FieldType.Text,analyzer = "ik_max_word")
    private String goodsName;

    @Field(name = "goods_intro",type = FieldType.Text,analyzer = "ik_smart")
    private String goodsIntro;

    @Field(name = "goods_category_id",type = FieldType.Long)
    private Long goodsCategoryId;

    @Field(name = "goods_cover_img",type = FieldType.Keyword)
    private String goodsCoverImg;

    @Field(name = "original_price",type = FieldType.Integer)
    private Integer originalPrice;

    @Field(name = "selling_price",type = FieldType.Integer)
    private Integer sellingPrice;

    //2019-09-18T05:38:32.000Z
    @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
    @Field(name = "create_time",type = FieldType.Date, format = DateFormat.custom,
            pattern = "uuuu-MM-dd'T'HH:mm:ss.SSSX")
    private Date createTime;
}
